import { SellesModule } from './selles/selles.module';
import { BannersModule } from './banners/banners.module';
import { CategoriesModule } from './categories/categories.module';
import { Module, MiddlewareConsumer, RequestMethod } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypegooseModule } from 'nestjs-typegoose'
import { MulterModule } from '@nestjs/platform-express';
import { AuthModule } from './auth/auth.module';
import { RolesModule } from './roles/roles.module';
import { ActionModule } from './actions/actions.module';
import { CommoditiesModule } from './commodities/commodities.module';
import { CommentsModule } from './comments/comments.module'
import { OrdersModule } from './orders/orders.module';


import { PermissionModule } from './permission/permission.module';
import { ServicesModule } from './services/services.module';

import MAO = require('multer-aliyun-oss');
import { MiddlewaresModule } from './middleware/middlewares.module';
import { AuthMiddleware } from './middleware/Auth.middleware';
import { DbModule } from '@lib/db';

@Module({
  imports: [
    CategoriesModule,
    BannersModule,
    AuthModule,
    RolesModule,
    ActionModule,
    CommoditiesModule,
    SellesModule,
    CommentsModule,
    PermissionModule,
    OrdersModule,
    ServicesModule,
    MiddlewaresModule,
    
    DbModule,

    MulterModule.registerAsync({
      useFactory() {
        return {
          storage: MAO({
            config: {
              region: 'oss-accelerate',
              accessKeyId: 'LTAI4FkijuixnUHtpPGTLo9f',
              accessKeySecret: 'yT3Uo0WIxuXJYGTGxH1EuFedTBbpFu',
              bucket: 'vue-nest'
            }
          })
        }
      }
    }),
  ],
  controllers: [
    AppController,
  ],
  providers: [AppService],
})
export class AppModule {
  // configure(consumer: MiddlewareConsumer) {
  //   consumer
  //     .apply(AuthMiddleware)
  //     .forRoutes({ path: '*', method: RequestMethod.ALL });
  // }
 }
